#ifndef __AUDIO_H
#define __AUDIO_H

#include <Arduino.h>
#include "driver/i2s.h"
#include "AudioGeneratorMP3.h"

#define INMP441_WS 40
#define INMP441_SCK 41
#define INMP441_SD 42

// todo 这里用新pcb要交换下pin
#define MAX98357_LRC 16
#define MAX98357_BCLK 17
#define MAX98357_DIN 18

#define SAMPLE_RATE 44100
#define GAIN_DEFAULT 0.4

void audio_init();
void audio_test_record();
void audio_test_mic_to_speaker();

void audio_inmp441_init();
void audio_inmp441_test();
void audio_inmp441_test_print(int16_t *buffer, size_t bytes);

void audio_max98357_init();

// #define MP3_URL_TEST         "http://music.163.com/song/media/outer/url?id=1751796.mp3"
#define MP3_URL_TEST         "http://music.163.com/song/media/outer/url?id=22169707.mp3" // MY WAY
// #define MP3_URL_TIMER_FINISH "http://music.163.com/song/media/outer/url?id=2715051279.mp3" // 三界四洲
#define MP3_URL_TIMER_FINISH "http://music.163.com/song/media/outer/url?id=1417892393.mp3"

void audio_max98357_mp3_init();
void audio_max98357_mp3_start();
void audio_max98357_mp3_play(const char *url, bool force);
void audio_max98357_mp3_loop();
void audio_max98357_mp3_stop();

void audio_spectrum_anim();

#endif